package com.baizhi.service.impl;

import com.baizhi.dao.iPhoneDao;
import com.baizhi.entity.iPhone;
import com.baizhi.service.iPhoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class iPhoneServiceImpl implements iPhoneService {
    @Autowired
    private iPhoneDao iphoneDao;
    @Override
    public void insert(iPhone iphone) {
        iphoneDao.insert(iphone);
    }

    @Override
    public void deleteById(Integer id) {
        iphoneDao.deleteById(id);
    }

    @Override
    public void deleteMany(List<Integer> ids) {
        iphoneDao.deleteMany(ids);
    }

    @Override
    public void update(iPhone iphone) {
        iphoneDao.update(iphone);
    }

    @Override
    public int totalRows() {
        return iphoneDao.totalRows();
    }

    @Override
    public iPhone selectById(Integer id) {
        return iphoneDao.selectById(id);
    }

    @Override
    public List<iPhone> selectAll(Integer pageNum, Integer pageSize) {
        Integer offset = (pageNum-1)*pageSize;
        Integer limit = pageSize;
        return iphoneDao.selectAll(offset,limit);
    }
}
